*******************************************************************************
/*

Master replication file for Lee, Zhang, and Herchenroder, "From Pluribus to Unum?"

Set your working directory to the location where you unzipped your files. 
Then run the master replication file, "LZH_replication.do", located in the 
"code" folder. All tables and figures will appear in the "output" folder.

Note that the master replication file is structured so that you *only need to 
run this file*, NOT the individual do files for each table and figure.

Note also that the individual do files load the appropriate dataset and create 
additional variables that are analysis-specific. 

*/ 

*******************************************************************************


*****************
* preliminaries *
*****************

* filepaths
* --------
set more off
set seed 123

capture global wd = // SET YOUR WORKING DIRECTORY HERE 
global dopath = "code/"
global clean = "data/"
global output "output/"

cd "${wd}"


* graphing stuff
* --------------

/* Turn on for color graphics
global blue = "66 133 244"
global red = "219 68 55"
global orange = "244 160 0"
global green = "15 157 88"
global purple = "127 34 147"
global magenta = "255 0 255"
global black = "0 0 0"
global none = "none"
*/

* Turn off for color graphics
global blue = "0 0 0"
global red = "100 100 100"
global orange = "0 0 0"
global green = "100 100 100"
global purple = "0 0 0"
global magenta = "100 100 100"
global black = "0 0 0"
global none = "none"




set scheme lean2


* regression controls
* -------------------
global county_npcontrols = "county_surban county_spostoffice county_srugged county_anyriver county_anycanal" 
global county_bcontrols = "birth_county_surban birth_county_spostoffice birth_county_srugged birth_county_anyriver birth_county_anycanal"
global life_controls = "sborn college usmilitary"
global state_npcontrols = "state_surban state_spostoffice state_srugged state_anyriver state_anycanal" 
global state_bcontrols = "birth_state_surban birth_state_spostoffice birth_state_srugged birth_state_anyriver birth_state_anycanal"

*******************************************************************************

*******************************************************************************


* --------- *
* Main Text *
* --------- *

global main = "${dopath}1.main/"

* Figure 1: Sectional Trend Plot with Acceleration
do "${main}np_ns_bubbles_acceleration_vertical.do"

* Figure 2: Pre-War Comparisons
do "${main}np_ns_prewar_compare.do"

* Figure 3: Northern Hypothesis, 1860 Cutoff
do "${main}np_north_1860.do"

* Figure 4: Northern Slope Changes, all cutpoints
do "${main}np_north_allcutpoints.do"

* Figure 5: Southern Hypothesis, 1865 Cutoff
do "${main}np_south_1865.do"

* Figure 6: Northern Republicans and Democrats
do "${main}congress_north_demrep_nowhig.do"

* Figure 7: Lincoln vs. McClellan
do "${main}np_lincoln.do"



* ----------------------- *
* Supplementary Materials *
* ----------------------- *

global appendix = "${dopath}2.appendix/"


* Figure S1: Figure 1 under different bandwidths
* --------------------------
do "${appendix}np_ns_acceleration_bw.do"


* Figures S2 and S3: SIMULATION ALL CUTPOINTS
* --------------------------
do "${appendix}simulation.do"



* Additional Newspaper Results
* ----------------------------

* Figure S4: Southern Slope Changes, all cutpoints
do "${appendix}np_south_allcutpoints.do"

* NOTE: Figure S5 Lincoln County Intercepts Shifts are produced in the main text do file where the slope changes are also plotted
* However, the intercept graphs are included in the appendix.

* Figure S6: Lincoln counties slope changes, all cutpoints
do "${appendix}np_lincoln_allcutpoints.do"

* Figure S7: McClellan counties slope changes, all cutpoints
do "${appendix}np_mcclellan_allcutpoints.do"




* Additional Congress Results
* ----------------------------

* Figure S8: Number of Statements made by Northern Congressmen, by Pre- vs Post-War and Party
do "${appendix}histogram_northerners.do"

* Table S1: Northern Congressmen Post-War Patterns, by Party
do "${appendix}congress_north_postwar.do"

* Figure S9: Number of Statements made by Southern Congressmen, by Pre-War, War, Reconstruction, and Post-Reconstruction
do "${appendix}histogram_southerners.do"

* Figure S10: Proportion former confederates and Democrats amongst Southerners
do "${appendix}southern_dems_rebels.do"


* DESCRIPTION: Southern Whigs Pre-War vs. Southern Republicans Post-War (until 1876)
do "${appendix}southern_republicans.do"

* ----------------------------------------- *
*	1 / 14 used singular pre-war (7%)		*
*	16 / 23 used singular post-war (70%)	*
*	Chi2 (1) = 13.7, p<0.001				*
* ----------------------------------------- *

* Figure S11: Southern Trend Plot
do "${appendix}congress_southdem_bubbles.do"

* Table S2: Full Regression Model of Southern Democrats
do "${appendix}congress_southdem_fulltable.do"



* ------------------ *
* Dataverse Appendix *
* ------------------ *


* Tables D1 and D2: Descriptives Table
* --------------------------
do "${appendix}descriptives_table.do"


* Full Tables: Results from Main Text
* ------------------------------------

* Tables D3 and D4: Newspaper Analysis at 1860 and 1865 Cutoffs
do "${appendix}np_ns_fulltable.do"

* Table D5: Northern Dems vs Northern Republicans in Congress
do "${appendix}congress_NDNR_fulltable.do"

* Table D6: Lincoln vs. McClellan Counties
do "${appendix}np_lincoln_fulltable.do"




* ROBUSTNESS: Including Border Areas
* ----------------------------------

* Figure D1 and Table D7
do "${appendix}np_northborder_1860.do"
do "${appendix}np_northborder_1860_table.do"

* Figure D2 and Table D8
do "${appendix}congress_northborder_demrep.do"
do "${appendix}congress_northborder_demrep_table.do"

* Figure D3 and Table D9
do "${appendix}np_northborder_lincoln.do"
do "${appendix}np_northborder_lincoln_table.do"



* ROBUSTNESS: County and State FEs
* ----------------------------------

* Figure D4 and Table D10
do "${appendix}np_north_1860_altfes.do"
do "${appendix}np_north_1860_altfes_table.do"

* Figure D5 and Table D11
do "${appendix}np_south_1865_altfes.do"
do "${appendix}np_south_1865_altfes_table.do"

* Figure D6 and Table D12
do "${appendix}np_lincoln_altfes.do"
do "${appendix}np_lincoln_altfes_table.do"



* ROBUSTNESS: State-level Covariates
* ----------------------------------

* Figure D7 and Table D13
do "${appendix}np_north_1860_statecontrols.do"
do "${appendix}np_north_1860_statecontrols_table.do"

* Figure D8 and Table D14
do "${appendix}np_south_1865_statecontrols.do"
do "${appendix}np_south_1865_statecontrols_table.do"

* Figure D9 and Table D15
do "${appendix}congress_north_demrep_statecontrols.do"
do "${appendix}congress_north_demrep_statecontrols_table.do"

* Figure D10 and Table D16
do "${appendix}np_lincoln_statecontrols.do"
do "${appendix}np_lincoln_statecontrols_table.do"







